<!--
 * @Author: zhangjingyu
 * @Date: 2021-04-13 09:33:48
 * @LastEditors: zhangjingyu
 * @LastEditTime: 2021-04-15 15:38:11
 * @FilePath: \vprisk10.14\src\views\ftpManage\pricingManage\hisBusiRepricing\rp_subTasks.vue
 * @Description: 重定价子任务页面
-->
<template>
  <div>
    <span class="formTitle"><i class="vertical-bar"></i>重定价子任务</span>

    <el-form
      :model="searchForm"
      ref="searchForm"
      label-width="100px"
      label-position="left"
      size="mini"
    >
      <el-row :gutter="30">
        <el-col :span="5">
          <el-form-item label="任务名称：" prop="taskName">
            <el-input
              v-model="taskName"
              maxlength="32"
              disabled
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="5">
          <el-form-item label="定价编号：" prop="pricingCode">
            <el-input
              v-model="searchForm.pricingCode"
              maxlength="32"
              disabled
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="5" >
          <el-form-item label="开始日期：" prop="taskSd">
            <el-input
              v-model="searchForm.taskSd"
              maxlength="32"
              disabled
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="5" >
          <el-form-item label="结束日期：" prop="taskEd">
            <el-input
              v-model="searchForm.taskEd"
              maxlength="32"
              disabled
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span='4'>
             <el-button @click="searchFunc">查询</el-button>
        </el-col>
      </el-row>
    
      <el-row class="container">
        <el-col style="margin-right:10px;" class="content-left">
          <upper-template :searchIcon="false" :configIcon="false">
            <!-- 操作按钮区 -->
            <template slot="buttonArea">
              <el-button @click="toEngine()">引擎任务</el-button>
              <el-button @click="toRecord()">执行记录</el-button>
              <el-button @click="goBack()">返回</el-button>
            </template>
          </upper-template>
        </el-col>
      </el-row>
      <el-table
        ref="multipleTable"
        :data="tableData"
        style="width: 100%"
        @row-click="rowClick"
      >
        <el-table-column
          prop="pricingCode"
          label="定价编号"
          :show-overflow-tooltip="true"
        ></el-table-column>
        <el-table-column
          prop="subTaskCode"
          label="子任务编号"
          :show-overflow-tooltip="true"
        ></el-table-column>
        <el-table-column
          prop="dataDate"
          label="数据日期"
          :show-overflow-tooltip="true"
        ></el-table-column>
        <el-table-column
          prop="startTm"
          label="开始时间"
          :show-overflow-tooltip="true"
        ></el-table-column>
        <el-table-column
          prop="endTm"
          label="结束时间"
          :show-overflow-tooltip="true"
        ></el-table-column>
        <el-table-column
          prop="status"
          label="运行状态"
          :show-overflow-tooltip="true"
          :formatter="r=>$getLabel(r.status,statusOption)"
        ></el-table-column>
      </el-table>
      <!-- 分页插件 -->
      <pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="searchForm.page"
        :page-size="searchForm.size"
        @refresh="searchFunc"
        :total="total"
      ></pagination>
    </el-form>
  </div>
</template>

<script>
import { pricingTask } from "@/api/index";
import moment from "moment"
export default {
  props: {
    //选中的值
    baseData: {
      type: Object,
      default: () => ({})
    }
  },
  data() {
    return {
        taskName:this.baseData.taskName,
      searchForm: {
        taskCode: this.baseData.taskCode,
        pricingCode: this.baseData.pricingCode,
        taskSd: this.baseData.taskSd,
        taskEd: this.baseData.taskEd,
        page: 1,
        size: 15
      },
      statusOption:[],
      tableData:[],
      total:0,
    };
  },
  created(){
      this.getDict()
  },
  mounted(){
      this.searchFunc()
  },
  methods: {
    //点击行选中
    rowClick(row) {
      if (this.$refs.multipleTable) {
        this.$refs.multipleTable.clearSelection();
      }
      this.$refs.multipleTable.toggleRowSelection(row, true);
    },
    getDict(){
         this.$getDict("ftp_pricing_task_status").then(res => {
        if (res.code == 200) {
          this.statusOption = res.datas;
        } 
      });
    },
    // 返回执行记录
    toRecord(){
        this.$emit('backExecuteNotes')
    },
    // 去引擎任务
    toEngine(){
        this.$emit('toEngine')
    },
    // 返回主页面
    goBack(){
        this.$emit('backIndex')
    },
    searchFunc() {
         let data =this.searchForm;
      pricingTask.pricingSubRecordFindAll(data).then(res => {
        if (res.code == 200) {
          this.tableData = res.datas.rows.map(v=>{
            let obj = v;
            obj.dataDate =obj.dataDate? moment(obj.dataDate).format('yyyy-MM-DD'):"-"
            return obj;
          });
          this.total = res.total;
        }
      });
    },
      handleSizeChange(val) {
      this.searchForm.size = val;
      this.searchFunc();
    },
    handleCurrentChange(val) {
      this.searchForm.page = val;
      this.searchFunc();
    },
  }
};
</script>

<style lang="scss" scoped>
</style>